package com.jblapp.icu.sms;

import java.util.List;

import org.apache.http.NameValuePair;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.jblapp.icu.http.Register;
import com.jblapp.icu.ui.RegisterConfirmActivity;

public class RegThread implements Runnable {
	private Context context = null;
	private Handler msgHandler = null;
	private Message msg = null;
	private List<NameValuePair> params = null;
	private Register register = null;
	private String status = null;
	private final static String TAG = "RegThread";

	public RegThread(Context context, Handler msgHandler,
			List<NameValuePair> params) {
		this.context = context;
		this.msgHandler = msgHandler;
		this.params = params;
	}

	@Override
	public void run() {
		register = new Register( null, params);
		msg = new Message();
		try {
			status = register.regStatus();
			Log.e(TAG, "RegisterStatus:"+status);
		} catch (Exception e) {
			msg.what = RegisterConfirmActivity.ERROR;
			e.printStackTrace();
		}
		if (null == status) {
			msg.what = RegisterConfirmActivity.ERROR;
		} else {
			msg.what = RegisterConfirmActivity.GETUNIPID;
			msg.obj=status;
		}
		msgHandler.sendMessage(msg);
	}
}
